package ru.bragnikita.test.ws.math.service;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import java.util.Date;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * User: Nikita
 * Date: 27.01.13
 * Time: 18:11
 * To change this template use File | Settings | File Templates.
 */
@WebService(name = "MathServiceDefaultPortType", targetNamespace = Constants.SERVICE_NS, serviceName = "MathService", portName = "MathOperations")
public class MathService {

    private String creationTime;

    public MathService() {
        creationTime = new Date().toString();
    }

    @WebMethod(action = "EvaluateExpression", operationName = "EvaluateExpressionOp")
    public MathResult evaluate(@WebParam(mode = WebParam.Mode.IN, name = "EvalParams", partName = "EvalParamsPart")
                                   Parameters params) {

        MathResult mathResult = new MathResult();
        mathResult.setSourceExpresson(params.getExpression());
        mathResult.setUsername(params.getUsername());
        EvaluationResult result = new EvaluationResult();
        result.setEvaluated(false);
        result.setErrorText("Service has no implementation yet. Handler object id = " + creationTime);
        mathResult.setResult(result);

        return mathResult;
    }

}
